package com.feng.eduservice.controller;


import com.feng.commonutils.R;
import com.feng.eduservice.entity.EduVideo;
import com.feng.eduservice.service.EduChapterService;
import com.feng.eduservice.service.EduVideoService;
import com.feng.eduservice.vo.course.videoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author fengge
 * @since 2023-01-17
 */
@RestController
@RequestMapping("/eduservice/video")
@CrossOrigin
public class EduVideoController {
    @Autowired
    private EduVideoService eduVideoService;
    //添加小节
    @PostMapping("addVideo")
    public R addVideo(@RequestBody EduVideo eduVideo){
        eduVideoService.save(eduVideo);
        return R.ok();
    }
    @DeleteMapping("{id}")
     public R deleteVideo(@PathVariable String id){
        return  eduVideoService.removeVideoById(id);

    }
    @PostMapping("update")
    public R updateVideo(@RequestBody EduVideo eduVideo){
        eduVideoService.updateById(eduVideo);
        return R.ok();
    }
    @GetMapping("{id}")
    public R getVideoInfo(@PathVariable String id){
        return eduVideoService.getVideoInfo(id);
    }

}

